﻿using TrueSync;
using System.Collections.Generic;

public class LogicStatusComponent : LogicComponent
{
    LogicEntity mLEntity;
    Dictionary<string, int> Properties;

    public int HP
    {
        get; set;
    }

    public int Energy
    {
        get; set; 
    }

    public int Dizzy
    {
        get; set;
    }

    public int this[string propertyName]
    {
        get
        {
            return Properties.ContainsKey(propertyName) ? Properties[propertyName] : 0;
        }

        set
        {
            Properties[propertyName] = value; 
        }
    }

    public const int MAX_DIZZY = 100;

    public void Init(LogicEntity LEntity)
    {
        mLEntity = LEntity;
        HP = 100;
        ResetDizzy();
    }

    public void Start()
    {
    }
    
    public void DoUpdate(FP deltaTime)
    {
        
    }

    public void Destroy()
    {
        mLEntity = null;
    }

    public void DoDamage(int hp)
    {
        HP -= hp;
    }

    public bool UseEnergy(int useEnergy)
    {
        if (Energy < useEnergy)
            return false;
        Energy -= useEnergy;
        return true;
    }

    public void DoDizzy(int dizzy)
    {
        Dizzy -= dizzy;
    }

    public void ResetDizzy()
    {
        Dizzy = MAX_DIZZY;
    }
}
